#include "HelloWorldScene.h"

USING_NS_CC;

Scene* HelloWorld::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    
    // 'layer' is an autorelease object
    auto layer = HelloWorld::create();

    // add layer as a child to scene
    scene->addChild(layer);
    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
	if (!LayerColor::initWithColor(Color4B(255, 255, 255, 255))) {
		return false;
	}
	test = Sprite::create("Player.png");
	auto test2 = Sprite::create("Player.png");
	auto  winSize = Director::getInstance()->getWinSize();
	test2->setPosition(Point(winSize.width / 2 + 2, winSize.height+ 2));
	test->setPosition(Point(50,50));
	this->addChild(test);
	this->addChild(test2);
	this->bezier(1);
	//this->schedule(schedule_selector(HelloWorld::move), 1.0);
    return true;
}
void HelloWorld::bezier(float dt){
	ccBezierConfig beziercf;
	beziercf.controlPoint_1 = Point(100, 100);
	beziercf.controlPoint_2 = Point(200, -200);
	beziercf.endPosition = Point(40, 400);
	auto action = BezierBy::create(3,beziercf);
	test->runAction(action);
}
void HelloWorld::jumpBy(float dt){
	auto action = JumpBy::create(3, Vec2(150, 150), 50, 5);
	test->runAction(action);
}
void HelloWorld::moveBy(float dt){
	auto action = MoveBy::create(3, Vec2(150, 50));
	test->runAction(action);
}

void HelloWorld::moveTo(float dt){
	auto action = MoveTo::create(3, Vec2(150, 50));
	test->runAction(action);
}
void HelloWorld::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
	MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
    return;
#endif

    Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
}
